﻿@model DLMemberPointMS.Entity.ViewModel.ShopEditViewModel

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/layui/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <title>新增会员等级</title>
    <style>
        .layui-form-label {
            width: 100px
        }
    </style>

</head>
<body>
    <fieldset class="layui-elem-field layui-field-title">
        <legend>新增店铺</legend>
    </fieldset>
    @using (Html.BeginForm("", "", FormMethod.Post, new { @class = "layui-form", id = "form_Shops" }))
    {

        <div class="layui-form-item">
            <label class="layui-form-label">店铺名称</label>
            <div class="layui-input-inline">
                @Html.EditorFor(model => model.S_Name, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">店铺类型</label>
            <div class="layui-input-inline">
                @Html.DropDownList("S_Category", ViewData["Enum"] as IEnumerable<SelectListItem>, new { htmlAttributes = new { @class = "layui-input" } })

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人</label>
            <div class="layui-input-inline">
                @Html.EditorFor(model => model.S_ContactName, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
                @Html.ValidationMessageFor(model => model.S_ContactName, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-inline">
                @Html.EditorFor(model => model.S_ContactTel, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required|phone|number" } })
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">店铺地址</label>
            <div class="layui-input-inline">
                @Html.EditorFor(model => model.S_Address, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                @Html.EditorFor(model => model.S_Remark, new { htmlAttributes = new { @class = "layui-input" } })
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">

                <button class="layui-btn" lay-submit lay-filter="submitform" id="BtnAdd">新增</button>
            </div>
        </div>
        @Html.HiddenFor(Model => Model.S_ID)
    }

    <script>
        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            var layer = layui.layer;//弹窗

            $("#BtnAdd").click(function () {
                //添加事件进添加方法
                var url = "/Shops/GetAddShopList";
                var i = parent.layer.getFrameIndex(window.name);
                //serializeArray() 方法通过序列化表单值来创建对象数组（名称和值），返回 JSON 数据结构数据
                //返回的 JSON 对象是由一个对象数组组成的，其中每个对象包含一个或两个名值对 —— name 参数和 value 参数
                var fromdata = $("#form_Shops").serializeArray();
                //获取id
                var S_ID = $('#S_ID').val();
                if (parseInt(S_ID) > 0) {
                    url = "/Shops/UpdeShop";
                }
                $.ajax({
                    type: "post",
                    url: url,
                    data: fromdata,
                    success: function (res) {
                        if (res.code == 0) {

                            parent.layer.msg(res.msg, { icon: 1 });
                            parent.layer.close(i); //再执行关闭

                        } else {
                            parent.layer.msg(res.msg, { icon: 5 });
                            parent.layer.close(i); //再执行关闭
                        }
                    },
                    error: function (res) {
                        parent.layer.msg(res.msg, { icon: 2 });
                        parent.layer.close(i); //再执行关闭

                    }
                })
                return false;
            })


        })
    </script>

</body>
</html>
